//
//  ApplyOilFifthVC.m
//  Base_App
//
//  Created by Yutian Duan on 2019/6/18.
//  Copyright © 2019年 Wanwin. All rights reserved.
//

#import "ApplyOilFifthVC.h"
#import "ApplyeOilHeadView.h"

@interface ApplyOilFifthVC ()
@property (nonatomic, strong) ApplyeOilHeadView *stepHeadView;
@property (nonatomic, strong) UIScrollView *contenView;
@end

@implementation ApplyOilFifthVC

- (void)viewDidLoad {
  [super viewDidLoad];
  // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated {
  [super viewWillAppear:animated];
  //  [self setDefaltNavBar];
  [self.navigationController setNavigationBarHidden:NO animated:animated];
  [self setNavImage:[UIImage imageNamed:@"Home_BgImage"] titleColor:[UIColor whiteColor]];
  [self setStatusBarStyleWhite];
  
}

- (void)createFields {
  [super createFields];
  self.navigationItem.title = YTLocalizedString(@"油咭申请");
  [self createWhiteBack];
  
}

- (void)createViews {
  
  [super createViews];
  
  _contenView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, NavBarHeight, ScreenWidth, ScreenHeight - NavBarHeight)];
  [self.view addSubview:_contenView];
  
  _stepHeadView = [[ApplyeOilHeadView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenWidth * ITEMPRO)];
  _stepHeadView.stepCount = 4;
  _stepHeadView.userInteractionEnabled = NO;
  _stepHeadView.isPersonal = _applyModel.isPersonal;
  [_contenView addSubview:_stepHeadView];
  
  
  CGFloat fontF = 13.5f;
  if (IS_IPHONE5) {
    fontF = 11.5f;
  }
  
  UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, _stepHeadView.yt_bottom + 20, _contenView.yt_width - 30, 30)];
  titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:18.0f];
  titleLabel.textColor = [UIColor blackColor];
  titleLabel.textAlignment = NSTextAlignmentLeft;
  titleLabel.text = YTLocalizedString(@"您的申请已提交");
  [_contenView addSubview:titleLabel];

  
  UIImageView *tickImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, titleLabel.yt_bottom + 20, 80, 80)];
  tickImageView.image = [UIImage imageNamed:@""];
  tickImageView.yt_centerX = _contenView.yt_centerX;
  [_contenView addSubview:tickImageView];

  UILabel *desLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, tickImageView.yt_bottom + 20, _contenView.yt_width - 80, 0)];
  desLabel.numberOfLines = 0;
  desLabel.font = [UIFont systemFontOfSize:fontF];
  [_contenView addSubview:desLabel];

  
  NSString *desStr = YTLocalizedString(@"您的油咭资料已成功提交并传送到相关部门做进一步批核，我们将于3-5个工作天内联系您，期间请保持电话畅通，留意我们的来电号码：3166-6550进行资料核对，你也可与「油咭」页面随时查看批核进度，感谢您对我们的信赖及支持！");
  
  
  NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:desStr];

  NSRange range1 = [desStr rangeOfString:YTLocalizedString(@"成功提交")];
  NSRange range2 = [desStr rangeOfString:YTLocalizedString(@"3-5")];
  NSRange range3 = [desStr rangeOfString:YTLocalizedString(@"3166-6550")];
  NSRange range4 = [desStr rangeOfString:YTLocalizedString(@"「油咭」")];
  NSRange range5 = [desStr rangeOfString:YTLocalizedString(@"批核进度")];

  [noteStr addAttribute:NSForegroundColorAttributeName value:DEF_RED range:range1];
  [noteStr addAttribute:NSForegroundColorAttributeName value:DEF_RED range:range2];
  [noteStr addAttribute:NSForegroundColorAttributeName value:DEF_RED range:range3];
  [noteStr addAttribute:NSForegroundColorAttributeName value:DEF_RED range:range4];
  [noteStr addAttribute:NSForegroundColorAttributeName value:DEF_RED range:range5];

  [noteStr addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Helvetica-Bold" size:18.0f] range:range3];

  desLabel.attributedText = noteStr;
  [desLabel sizeToFit];
  
  
  UIButton *lookStepButton = [[UIButton alloc] initWithFrame:CGRectMake(0, desLabel.yt_bottom + 30, 30 * 5, 30)];
  [lookStepButton setTitle:YTLocalizedString(@"查看申请进度") forState:UIControlStateNormal];
  [lookStepButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  lookStepButton.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:18.0f];
  lookStepButton.backgroundColor = DEF_RED;
  lookStepButton.layer.masksToBounds = YES;
  lookStepButton.layer.cornerRadius = 8;
  [lookStepButton addTarget:self action:@selector(lookClick) forControlEvents:UIControlEventTouchUpInside];
  lookStepButton.yt_centerX = _contenView.yt_centerX;
  [_contenView addSubview:lookStepButton];
  
  
}

- (void)loadData {
  [super loadData];
  
  
}

- (void)lookClick {
  
  [ToolsServer sharedInstance].isBindCard = YES;
  
  [self.tabBarController setSelectedIndex:1];
  [self.navigationController popToRootViewControllerAnimated:YES];
  
}

@end

